/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package table.model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import obj.Appointment;

/**
 *
 * @author John
 */
public class AppointmentTableModel extends AbstractTableModel {

    String[] columnNames = {  "Doctor", "Patient", "Date/Time", "Status" };
    ArrayList<Appointment> listOfAppointments;

    public AppointmentTableModel() {
        listOfAppointments = new ArrayList<Appointment>();
    }
    
    
    
    @Override
    public int getRowCount() {
        return listOfAppointments.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex) {
            case 0: //column names
                return listOfAppointments.get(rowIndex).getDoctorID();
            case 1:
                return listOfAppointments.get(rowIndex).getPersonID();
            case 2: 
                return listOfAppointments.get(rowIndex).getScheduledDate();
            case 3:
                return listOfAppointments.get(rowIndex).getAppointmentStatusID();
            default:
                return null;
        }
    }
    
    public void addAppoinetment(Appointment appointment) {
        listOfAppointments.add(appointment);
    }
    
}
